package com.wxy.config;

import com.wxy.domain.MyException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author 47868
 */
@ControllerAdvice
public class ExceptionHandler{
    @org.springframework.web.bind.annotation.ExceptionHandler(Exception.class)
    public ModelAndView exception(Exception e){
        ModelAndView mv = new ModelAndView();
        mv.setViewName("error");
        mv.addObject("msg",e.getMessage());
        return mv;
    }
    @org.springframework.web.bind.annotation.ExceptionHandler(MyException.class)
    public ModelAndView exception(MyException e){
        ModelAndView mv = new ModelAndView();
        mv.setViewName("error");
        mv.addObject("msg",e.getMessage());
        return mv;
    }
}
